﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IFRS.Web;
using IFRS.Models;
using IFRS.DataAccess.DAL;
using System.Data;
using IFRS_Global;
using System.Globalization;
using System.Threading;
using vsm.CustomControl;

public partial class IFRS_WIN31_GL_TR_2E : PageBase
{
    #region "---------- Properties -----------"
    public string SrciptSetValueGlAccountGl = string.Empty;
    #endregion
    #region "---------- Events -----------"
    protected void Page_Load(object sender, EventArgs e)
    {
        Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
        if (!(Page.IsPostBack || Page.IsCallback))
        {            
            this.AddClientScript();
            this.ViewMenu();
            this.BindControl();
            if (Request.QueryString["id"] != null)
            {
                this.BindData(Convert.ToInt32(Request.QueryString["id"].ToString()));
            }
        }
        else
            ClientScript.RegisterHiddenField("isPostBack", "1");

        this.SetValueGlAccountGl();
    }    
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        SaveData(false);
    }
    protected void btnCANCEL_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/IFRS/WIN31_1S.aspx");
    }
    #endregion
    #region "---------- Methods -----------"
    private void AddClientScript()
    {
        btnCANCEL.Attributes["OnClick"] = "if(!confirm(\"" + Resources.ifrsResource.ConfirmCancel + "\")) return false;";
    }
    private string Gen_Srcipt_SetValueGLAccount_GL(HiddenField hddField, TextboxAutoComplete textboxAutoComplete, TextBox textBox)
    {
        var script = string.Empty;
        script += String.Format("if('{0}' == Value4)", textboxAutoComplete.ID);
        script += " {";
        script += String.Format("document.getElementById('{0}').value = Value1;", hddField.ClientID);
        script += String.Format("document.getElementById('{0}').value = Value2;", textboxAutoComplete.ClientID);
        script += String.Format("document.getElementById('{0}').value = Value3;", textBox.ClientID);
        script += " }";
        return script;
    }
    private void SetValueGlAccountGl()
    {
        SrciptSetValueGlAccountGl += "<script type='text/javascript'>window.SetValueGLAccount_GL = function (Value1, Value2, Value3, Value4) {  ";
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ACCOUNT, txtGL_ACCOUNT, txtGL_ACCOUNT_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ADJ_INT_INC_PL, txtGL_ADJ_INT_INC_PL, txtGL_ADJ_INT_INC_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ADJ_FV_BS, txtGL_ADJ_FV_BS, txtGL_ADJ_FV_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ADJ_INT_INC_ELCLS_PL, txtGL_ADJ_INT_INC_ELCLS_PL, txtGL_ADJ_INT_INC_ELCLS_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ADJ_CST_BS, txtGL_ADJ_CST_BS, txtGL_ADJ_CST_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_REV_CST_PL, txtGL_REV_CST_PL, txtGL_REV_CST_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ADJ_FEE_BS, txtGL_ADJ_FEE_BS, txtGL_ADJ_FEE_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_REV_FEE_PL, txtGL_REV_FEE_PL, txtGL_REV_FEE_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_SUBSEQ_ADJ_CST_BS, txtGL_SUBSEQ_ADJ_CST_BS, txtGL_SUBSEQ_ADJ_CST_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_SUBSEQ_ADJ_FEE_BS, txtGL_SUBSEQ_ADJ_FEE_BS, txtGL_SUBSEQ_ADJ_FEE_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_IMP_LOSS_PL, txtGL_IMP_LOSS_PL, txtGL_IMP_LOSS_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ALLW_BAD_DEBT_PL, txtGL_ALLW_BAD_DEBT_PL, txtGL_ALLW_BAD_DEBT_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_WOFF_ADJ_FV_BS, txtGL_WOFF_ADJ_FV_BS, txtGL_WOFF_ADJ_FV_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_WOFF_ADJ_FEE_BS, txtGL_WOFF_ADJ_FEE_BS, txtGL_WOFF_ADJ_FEE_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_WOFF_ADJ_CST_BS, txtGL_WOFF_ADJ_CST_BS, txtGL_WOFF_ADJ_CST_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_DAY1_FV_LOSS_PL, txtGL_DAY1_FV_LOSS_PL, txtGL_DAY1_FV_LOSS_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_DAY1_ADJ_FV_BS, txtGL_DAY1_ADJ_FV_BS, txtGL_DAY1_ADJ_FV_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_WOFF_INT_DISC_LN, txtGL_WOFF_INT_DISC_LN, txtGL_WOFF_INT_DISC_LN_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_DAY1_DEF_EXP_STAFF_BS, txtGL_DAY1_DEF_EXP_STAFF_BS, txtGL_DAY1_DEF_EXP_STAFF_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_AMC_EMP_CST_PL, txtGL_AMC_EMP_CST_PL, txtGL_AMC_EMP_CST_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_AMC_DEF_EXP_STAFF_BS, txtGL_AMC_DEF_EXP_STAFF_BS, txtGL_AMC_DEF_EXP_STAFF_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_SUBSIDY_INT_REC_BS, txtGL_SUBSIDY_INT_REC_BS, txtGL_SUBSIDY_INT_REC_BS_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_SUBSIDY_INT_INC_PL, txtGL_SUBSIDY_INT_INC_PL, txtGL_SUBSIDY_INT_INC_PL_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ACC_SUBSIDY_REV_CHG, txtGL_ACC_SUBSIDY_REV_CHG, txtGL_ACC_SUBSIDY_REV_CHG_NAME);
        SrciptSetValueGlAccountGl += Gen_Srcipt_SetValueGLAccount_GL(hidGL_ADJ_SUBSIDY_REV_CHG, txtGL_ADJ_SUBSIDY_REV_CHG, txtGL_ADJ_SUBSIDY_REV_CHG_NAME);
        SrciptSetValueGlAccountGl += " }</script>";
    }
    private void SetTextboxAutoComplete(HiddenField hddField, TextboxAutoComplete textboxAutoComplete, TextBox textBox)
    {
        textboxAutoComplete.AddControl(hddField.ClientID);
        textboxAutoComplete.AddControl(textboxAutoComplete.ClientID);
        textboxAutoComplete.AddControl(textBox.ClientID);
        textboxAutoComplete.ControlSearch = textboxAutoComplete.ClientID;
        textboxAutoComplete.SearchKey = "GLAccount_oGLAccountCode_oGLAccountName_GL";
    }
    private void SetButtonPopup(Button button, TextboxAutoComplete textboxAutoComplete)
    {
        button.Attributes.Add("onClick", "return popWindow('" + ResolveUrl("~/PopupPages/GLAccount_GL.aspx?&PopUp=" + textboxAutoComplete.ID) + "','700','550');");
    }
    private void BindControl()
    {
        btnSAVE.ValidationGroup = "Master";        

        SetButtonPopup(btnGL_ACCOUNT, txtGL_ACCOUNT);
        SetButtonPopup(btnGL_ADJ_INT_INC_PL, txtGL_ADJ_INT_INC_PL);
        SetButtonPopup(btnGL_ADJ_FV_BS, txtGL_ADJ_FV_BS);
        SetButtonPopup(btnGL_ADJ_INT_INC_ELCLS_PL, txtGL_ADJ_INT_INC_ELCLS_PL);
        SetButtonPopup(btnGL_ADJ_CST_BS, txtGL_ADJ_CST_BS);
        SetButtonPopup(btnGL_REV_CST_PL, txtGL_REV_CST_PL);
        SetButtonPopup(btnGL_ADJ_FEE_BS, txtGL_ADJ_FEE_BS);
        SetButtonPopup(btnGL_REV_FEE_PL, txtGL_REV_FEE_PL);
        SetButtonPopup(btnGL_SUBSEQ_ADJ_CST_BS, txtGL_SUBSEQ_ADJ_CST_BS);
        SetButtonPopup(btnGL_SUBSEQ_ADJ_FEE_BS, txtGL_SUBSEQ_ADJ_FEE_BS);
        SetButtonPopup(btnGL_IMP_LOSS_PL, txtGL_IMP_LOSS_PL);
        SetButtonPopup(btnGL_ALLW_BAD_DEBT_PL, txtGL_ALLW_BAD_DEBT_PL);
        SetButtonPopup(btnGL_WOFF_ADJ_FV_BS, txtGL_WOFF_ADJ_FV_BS);
        SetButtonPopup(btnGL_WOFF_ADJ_FEE_BS, txtGL_WOFF_ADJ_FEE_BS);
        SetButtonPopup(btnGL_WOFF_ADJ_CST_BS, txtGL_WOFF_ADJ_CST_BS);
        SetButtonPopup(btnGL_DAY1_FV_LOSS_PL, txtGL_DAY1_FV_LOSS_PL);
        SetButtonPopup(btnGL_DAY1_ADJ_FV_BS, txtGL_DAY1_ADJ_FV_BS);
        SetButtonPopup(btnGL_WOFF_INT_DISC_LN, txtGL_WOFF_INT_DISC_LN);
        SetButtonPopup(btnGL_DAY1_DEF_EXP_STAFF_BS, txtGL_DAY1_DEF_EXP_STAFF_BS);
        SetButtonPopup(btnGL_AMC_EMP_CST_PL, txtGL_AMC_EMP_CST_PL);
        SetButtonPopup(btnGL_AMC_DEF_EXP_STAFF_BS, txtGL_AMC_DEF_EXP_STAFF_BS);
        SetButtonPopup(btnGL_SUBSIDY_INT_REC_BS, txtGL_SUBSIDY_INT_REC_BS);
        SetButtonPopup(btnGL_SUBSIDY_INT_INC_PL, txtGL_SUBSIDY_INT_INC_PL);
        SetButtonPopup(btnGL_ACC_SUBSIDY_REV_CHG, txtGL_ACC_SUBSIDY_REV_CHG);
        SetButtonPopup(btnGL_ADJ_SUBSIDY_REV_CHG, txtGL_ADJ_SUBSIDY_REV_CHG);

        SetTextboxAutoComplete(hidGL_ACCOUNT, txtGL_ACCOUNT, txtGL_ACCOUNT_NAME);
        SetTextboxAutoComplete(hidGL_ADJ_INT_INC_PL, txtGL_ADJ_INT_INC_PL, txtGL_ADJ_INT_INC_PL_NAME);
        SetTextboxAutoComplete(hidGL_ADJ_FV_BS, txtGL_ADJ_FV_BS, txtGL_ADJ_FV_BS_NAME);
        SetTextboxAutoComplete(hidGL_ADJ_INT_INC_ELCLS_PL, txtGL_ADJ_INT_INC_ELCLS_PL, txtGL_ADJ_INT_INC_ELCLS_PL_NAME);
        SetTextboxAutoComplete(hidGL_ADJ_CST_BS, txtGL_ADJ_CST_BS, txtGL_ADJ_CST_BS_NAME);
        SetTextboxAutoComplete(hidGL_REV_CST_PL, txtGL_REV_CST_PL, txtGL_REV_CST_PL_NAME);
        SetTextboxAutoComplete(hidGL_ADJ_FEE_BS, txtGL_ADJ_FEE_BS, txtGL_ADJ_FEE_BS_NAME);
        SetTextboxAutoComplete(hidGL_REV_FEE_PL, txtGL_REV_FEE_PL, txtGL_REV_FEE_PL_NAME);
        SetTextboxAutoComplete(hidGL_SUBSEQ_ADJ_CST_BS, txtGL_SUBSEQ_ADJ_CST_BS, txtGL_SUBSEQ_ADJ_CST_BS_NAME);
        SetTextboxAutoComplete(hidGL_SUBSEQ_ADJ_FEE_BS, txtGL_SUBSEQ_ADJ_FEE_BS, txtGL_SUBSEQ_ADJ_FEE_BS_NAME);
        SetTextboxAutoComplete(hidGL_IMP_LOSS_PL, txtGL_IMP_LOSS_PL, txtGL_IMP_LOSS_PL_NAME);
        SetTextboxAutoComplete(hidGL_ALLW_BAD_DEBT_PL, txtGL_ALLW_BAD_DEBT_PL, txtGL_ALLW_BAD_DEBT_PL_NAME);
        SetTextboxAutoComplete(hidGL_WOFF_ADJ_FV_BS, txtGL_WOFF_ADJ_FV_BS, txtGL_WOFF_ADJ_FV_BS_NAME);
        SetTextboxAutoComplete(hidGL_WOFF_ADJ_FEE_BS, txtGL_WOFF_ADJ_FEE_BS, txtGL_WOFF_ADJ_FEE_BS_NAME);
        SetTextboxAutoComplete(hidGL_WOFF_ADJ_CST_BS, txtGL_WOFF_ADJ_CST_BS, txtGL_WOFF_ADJ_CST_BS_NAME);
        SetTextboxAutoComplete(hidGL_DAY1_FV_LOSS_PL, txtGL_DAY1_FV_LOSS_PL, txtGL_DAY1_FV_LOSS_PL_NAME);
        SetTextboxAutoComplete(hidGL_DAY1_ADJ_FV_BS, txtGL_DAY1_ADJ_FV_BS, txtGL_DAY1_ADJ_FV_BS_NAME);
        SetTextboxAutoComplete(hidGL_WOFF_INT_DISC_LN, txtGL_WOFF_INT_DISC_LN, txtGL_WOFF_INT_DISC_LN_NAME);
        SetTextboxAutoComplete(hidGL_DAY1_DEF_EXP_STAFF_BS, txtGL_DAY1_DEF_EXP_STAFF_BS, txtGL_DAY1_DEF_EXP_STAFF_BS_NAME);
        SetTextboxAutoComplete(hidGL_AMC_EMP_CST_PL, txtGL_AMC_EMP_CST_PL, txtGL_AMC_EMP_CST_PL_NAME);
        SetTextboxAutoComplete(hidGL_AMC_DEF_EXP_STAFF_BS, txtGL_AMC_DEF_EXP_STAFF_BS, txtGL_AMC_DEF_EXP_STAFF_BS_NAME);
        SetTextboxAutoComplete(hidGL_SUBSIDY_INT_REC_BS, txtGL_SUBSIDY_INT_REC_BS, txtGL_SUBSIDY_INT_REC_BS_NAME);
        SetTextboxAutoComplete(hidGL_SUBSIDY_INT_INC_PL, txtGL_SUBSIDY_INT_INC_PL, txtGL_SUBSIDY_INT_INC_PL_NAME);
        SetTextboxAutoComplete(hidGL_ACC_SUBSIDY_REV_CHG, txtGL_ACC_SUBSIDY_REV_CHG, txtGL_ACC_SUBSIDY_REV_CHG_NAME);
        SetTextboxAutoComplete(hidGL_ADJ_SUBSIDY_REV_CHG, txtGL_ADJ_SUBSIDY_REV_CHG, txtGL_ADJ_SUBSIDY_REV_CHG_NAME);

        reqGLAccount.SetRequiredField(lblGL_ACCOUNT, txtGL_ACCOUNT, btnSAVE);

        txtGLGroup.Text = Resources.ifrsField.GLGroup_GL_TR;
    }    
    private void BindData(int ID)
    {
        List<GLAccountPosting> gLAccountPosting = new List<GLAccountPosting>();
        DataTable dt = new SPR_GLACCOUNTPOSTING().SEARCH_BYID(ID);
        if (dt.Rows.Count > 0)
        {

            ConvertHelper.ConvertDataTableToObject(dt, gLAccountPosting);

            hidGLAccountPostingID.Value=gLAccountPosting[0].GLAccountPostingID.ToString();
            hidGLGroupID.Value=gLAccountPosting[0].GLGroupID.ToString();
            hidGL_ACCOUNT.Value=gLAccountPosting[0].GLAccountID.ToString();

            #region 'Binding ID Value'
            hidGL_ADJ_INT_INC_PL.Value=gLAccountPosting[0].GL_ADJ_INT_INC_PL_ID.ToString();
            hidGL_ADJ_FV_BS.Value=gLAccountPosting[0].GL_ADJ_FV_BS_ID.ToString();
            hidGL_ADJ_INT_INC_ELCLS_PL.Value=gLAccountPosting[0].GL_ADJ_INT_INC_ELCLS_PL_ID.ToString();
            hidGL_ADJ_CST_BS.Value=gLAccountPosting[0].GL_ADJ_CST_BS_ID.ToString();
            hidGL_REV_CST_PL.Value=gLAccountPosting[0].GL_REV_CST_PL_ID.ToString();
            hidGL_ADJ_FEE_BS.Value=gLAccountPosting[0].GL_ADJ_FEE_BS_ID.ToString();
            hidGL_REV_FEE_PL.Value=gLAccountPosting[0].GL_REV_FEE_PL_ID.ToString();
            hidGL_SUBSEQ_ADJ_CST_BS.Value=gLAccountPosting[0].GL_SUBSEQ_ADJ_CST_BS_ID.ToString();
            hidGL_SUBSEQ_ADJ_FEE_BS.Value=gLAccountPosting[0].GL_SUBSEQ_ADJ_FEE_BS_ID.ToString();
            hidGL_IMP_LOSS_PL.Value=gLAccountPosting[0].GL_IMP_LOSS_PL_ID.ToString();
            hidGL_ALLW_BAD_DEBT_PL.Value=gLAccountPosting[0].GL_ALLW_BAD_DEBT_PL_ID.ToString();
            hidGL_WOFF_ADJ_FV_BS.Value=gLAccountPosting[0].GL_WOFF_ADJ_FV_BS_ID.ToString();
            hidGL_WOFF_ADJ_FEE_BS.Value=gLAccountPosting[0].GL_WOFF_ADJ_FEE_BS_ID.ToString();
            hidGL_WOFF_ADJ_CST_BS.Value=gLAccountPosting[0].GL_WOFF_ADJ_CST_BS_ID.ToString();
            hidGL_DAY1_FV_LOSS_PL.Value=gLAccountPosting[0].GL_DAY1_FV_LOSS_PL_ID.ToString();
            hidGL_DAY1_ADJ_FV_BS.Value=gLAccountPosting[0].GL_DAY1_ADJ_FV_BS_ID.ToString();
            hidGL_WOFF_INT_DISC_LN.Value=gLAccountPosting[0].GL_WOFF_INT_DISC_LN_ID.ToString();
            hidGL_DAY1_DEF_EXP_STAFF_BS.Value=gLAccountPosting[0].GL_DAY1_DEF_EXP_STAFF_BS_ID.ToString();
            hidGL_AMC_EMP_CST_PL.Value=gLAccountPosting[0].GL_AMC_EMP_CST_PL_ID.ToString();
            hidGL_AMC_DEF_EXP_STAFF_BS.Value=gLAccountPosting[0].GL_AMC_DEF_EXP_STAFF_BS_ID.ToString();
            hidGL_SUBSIDY_INT_REC_BS.Value=gLAccountPosting[0].GL_SUBSIDY_INT_REC_BS_ID.ToString();
            hidGL_SUBSIDY_INT_INC_PL.Value=gLAccountPosting[0].GL_SUBSIDY_INT_INC_PL_ID.ToString();
            hidGL_ACC_SUBSIDY_REV_CHG.Value=gLAccountPosting[0].GL_ACC_SUBSIDY_REV_CHG_ID.ToString();
            hidGL_ADJ_SUBSIDY_REV_CHG.Value=gLAccountPosting[0].GL_ADJ_SUBSIDY_REV_CHG_ID.ToString();
            #endregion

            #region 'Binding CODE Value'
            txtGL_ACCOUNT.Text = gLAccountPosting[0].GLAccount_CODE;
            txtGL_ADJ_INT_INC_PL.Text = gLAccountPosting[0].GL_ADJ_INT_INC_PL_CODE;
            txtGL_ADJ_FV_BS.Text = gLAccountPosting[0].GL_ADJ_FV_BS_CODE;
            txtGL_ADJ_INT_INC_ELCLS_PL.Text = gLAccountPosting[0].GL_ADJ_INT_INC_ELCLS_PL_CODE;
            txtGL_ADJ_CST_BS.Text = gLAccountPosting[0].GL_ADJ_CST_BS_CODE;
            txtGL_REV_CST_PL.Text = gLAccountPosting[0].GL_REV_CST_PL_CODE;
            txtGL_ADJ_FEE_BS.Text = gLAccountPosting[0].GL_ADJ_FEE_BS_CODE;
            txtGL_REV_FEE_PL.Text = gLAccountPosting[0].GL_REV_FEE_PL_CODE;
            txtGL_SUBSEQ_ADJ_CST_BS.Text = gLAccountPosting[0].GL_SUBSEQ_ADJ_CST_BS_CODE;
            txtGL_SUBSEQ_ADJ_FEE_BS.Text = gLAccountPosting[0].GL_SUBSEQ_ADJ_FEE_BS_CODE;
            txtGL_IMP_LOSS_PL.Text = gLAccountPosting[0].GL_IMP_LOSS_PL_CODE;
            txtGL_ALLW_BAD_DEBT_PL.Text = gLAccountPosting[0].GL_ALLW_BAD_DEBT_PL_CODE;
            txtGL_WOFF_ADJ_FV_BS.Text = gLAccountPosting[0].GL_WOFF_ADJ_FV_BS_CODE;
            txtGL_WOFF_ADJ_FEE_BS.Text = gLAccountPosting[0].GL_WOFF_ADJ_FEE_BS_CODE;
            txtGL_WOFF_ADJ_CST_BS.Text = gLAccountPosting[0].GL_WOFF_ADJ_CST_BS_CODE;
            txtGL_DAY1_FV_LOSS_PL.Text = gLAccountPosting[0].GL_DAY1_FV_LOSS_PL_CODE;
            txtGL_DAY1_ADJ_FV_BS.Text = gLAccountPosting[0].GL_DAY1_ADJ_FV_BS_CODE;
            txtGL_WOFF_INT_DISC_LN.Text = gLAccountPosting[0].GL_WOFF_INT_DISC_LN_CODE;
            txtGL_DAY1_DEF_EXP_STAFF_BS.Text = gLAccountPosting[0].GL_DAY1_DEF_EXP_STAFF_BS_CODE;
            txtGL_AMC_EMP_CST_PL.Text = gLAccountPosting[0].GL_AMC_EMP_CST_PL_CODE;
            txtGL_AMC_DEF_EXP_STAFF_BS.Text = gLAccountPosting[0].GL_AMC_DEF_EXP_STAFF_BS_CODE;
            txtGL_SUBSIDY_INT_REC_BS.Text = gLAccountPosting[0].GL_SUBSIDY_INT_REC_BS_CODE;
            txtGL_SUBSIDY_INT_INC_PL.Text = gLAccountPosting[0].GL_SUBSIDY_INT_INC_PL_CODE;
            txtGL_ACC_SUBSIDY_REV_CHG.Text = gLAccountPosting[0].GL_ACC_SUBSIDY_REV_CHG_CODE;
            txtGL_ADJ_SUBSIDY_REV_CHG.Text = gLAccountPosting[0].GL_ADJ_SUBSIDY_REV_CHG_CODE;
            #endregion

            #region 'Binging NAME Value'
            txtGL_ACCOUNT_NAME.Text = gLAccountPosting[0].GLAccount_NAME;
            txtGL_ADJ_INT_INC_PL_NAME.Text = gLAccountPosting[0].GL_ADJ_INT_INC_PL_NAME;
            txtGL_ADJ_FV_BS_NAME.Text = gLAccountPosting[0].GL_ADJ_FV_BS_NAME;
            txtGL_ADJ_INT_INC_ELCLS_PL_NAME.Text = gLAccountPosting[0].GL_ADJ_INT_INC_ELCLS_PL_NAME;
            txtGL_ADJ_CST_BS_NAME.Text = gLAccountPosting[0].GL_ADJ_CST_BS_NAME;
            txtGL_REV_CST_PL_NAME.Text = gLAccountPosting[0].GL_REV_CST_PL_NAME;
            txtGL_ADJ_FEE_BS_NAME.Text = gLAccountPosting[0].GL_ADJ_FEE_BS_NAME;
            txtGL_REV_FEE_PL_NAME.Text = gLAccountPosting[0].GL_REV_FEE_PL_NAME;
            txtGL_SUBSEQ_ADJ_CST_BS_NAME.Text = gLAccountPosting[0].GL_SUBSEQ_ADJ_CST_BS_NAME;
            txtGL_SUBSEQ_ADJ_FEE_BS_NAME.Text = gLAccountPosting[0].GL_SUBSEQ_ADJ_FEE_BS_NAME;
            txtGL_IMP_LOSS_PL_NAME.Text = gLAccountPosting[0].GL_IMP_LOSS_PL_NAME;
            txtGL_ALLW_BAD_DEBT_PL_NAME.Text = gLAccountPosting[0].GL_ALLW_BAD_DEBT_PL_NAME;
            txtGL_WOFF_ADJ_FV_BS_NAME.Text = gLAccountPosting[0].GL_WOFF_ADJ_FV_BS_NAME;
            txtGL_WOFF_ADJ_FEE_BS_NAME.Text = gLAccountPosting[0].GL_WOFF_ADJ_FEE_BS_NAME;
            txtGL_WOFF_ADJ_CST_BS_NAME.Text = gLAccountPosting[0].GL_WOFF_ADJ_CST_BS_NAME;
            txtGL_DAY1_FV_LOSS_PL_NAME.Text = gLAccountPosting[0].GL_DAY1_FV_LOSS_PL_NAME;
            txtGL_DAY1_ADJ_FV_BS_NAME.Text = gLAccountPosting[0].GL_DAY1_ADJ_FV_BS_NAME;
            txtGL_WOFF_INT_DISC_LN_NAME.Text = gLAccountPosting[0].GL_WOFF_INT_DISC_LN_NAME;
            txtGL_DAY1_DEF_EXP_STAFF_BS_NAME.Text = gLAccountPosting[0].GL_DAY1_DEF_EXP_STAFF_BS_NAME;
            txtGL_AMC_EMP_CST_PL_NAME.Text = gLAccountPosting[0].GL_AMC_EMP_CST_PL_NAME;
            txtGL_AMC_DEF_EXP_STAFF_BS_NAME.Text = gLAccountPosting[0].GL_AMC_DEF_EXP_STAFF_BS_NAME;
            txtGL_SUBSIDY_INT_REC_BS_NAME.Text = gLAccountPosting[0].GL_SUBSIDY_INT_REC_BS_NAME;
            txtGL_SUBSIDY_INT_INC_PL_NAME.Text = gLAccountPosting[0].GL_SUBSIDY_INT_INC_PL_NAME;
            txtGL_ACC_SUBSIDY_REV_CHG_NAME.Text = gLAccountPosting[0].GL_ACC_SUBSIDY_REV_CHG_NAME;
            txtGL_ADJ_SUBSIDY_REV_CHG_NAME.Text = gLAccountPosting[0].GL_ADJ_SUBSIDY_REV_CHG_NAME;
            #endregion

        }
    }       
    private void SaveData(bool IsConfirmed)
    {
        try
        {
            GLAccountPosting gLAccountPosting = new GLAccountPosting();

            gLAccountPosting.GLAccountPostingID = hidGLAccountPostingID.Value.AsInt32();
            gLAccountPosting.GLGroupID = 6; //  'GL_TR'     ธุรกรรมเงินกู้ยืมระหว่างธนาคาร
            gLAccountPosting.GLAccountID = hidGL_ACCOUNT.Value.AsIntIsnull();

            gLAccountPosting.GL_ADJ_INT_INC_PL_ID = hidGL_ADJ_INT_INC_PL.Value.AsIntIsnull();
            gLAccountPosting.GL_ADJ_FV_BS_ID = hidGL_ADJ_FV_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_ADJ_INT_INC_ELCLS_PL_ID = hidGL_ADJ_INT_INC_ELCLS_PL.Value.AsIntIsnull();
            gLAccountPosting.GL_ADJ_CST_BS_ID = hidGL_ADJ_CST_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_REV_CST_PL_ID = hidGL_REV_CST_PL.Value.AsIntIsnull();
            gLAccountPosting.GL_ADJ_FEE_BS_ID = hidGL_ADJ_FEE_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_REV_FEE_PL_ID = hidGL_REV_FEE_PL.Value.AsIntIsnull();
            gLAccountPosting.GL_SUBSEQ_ADJ_CST_BS_ID = hidGL_SUBSEQ_ADJ_CST_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_SUBSEQ_ADJ_FEE_BS_ID = hidGL_SUBSEQ_ADJ_FEE_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_IMP_LOSS_PL_ID = hidGL_IMP_LOSS_PL.Value.AsIntIsnull();

            gLAccountPosting.GL_ALLW_BAD_DEBT_PL_ID = hidGL_ALLW_BAD_DEBT_PL.Value.AsIntIsnull();
            gLAccountPosting.GL_WOFF_ADJ_FV_BS_ID = hidGL_WOFF_ADJ_FV_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_WOFF_ADJ_FEE_BS_ID = hidGL_WOFF_ADJ_FEE_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_WOFF_ADJ_CST_BS_ID = hidGL_WOFF_ADJ_CST_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_DAY1_FV_LOSS_PL_ID = hidGL_DAY1_FV_LOSS_PL.Value.AsIntIsnull();
            gLAccountPosting.GL_DAY1_ADJ_FV_BS_ID = hidGL_DAY1_ADJ_FV_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_WOFF_INT_DISC_LN_ID = hidGL_WOFF_INT_DISC_LN.Value.AsIntIsnull();
            gLAccountPosting.GL_DAY1_DEF_EXP_STAFF_BS_ID = hidGL_DAY1_DEF_EXP_STAFF_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_AMC_EMP_CST_PL_ID = hidGL_AMC_EMP_CST_PL.Value.AsIntIsnull();
            gLAccountPosting.GL_AMC_DEF_EXP_STAFF_BS_ID = hidGL_AMC_DEF_EXP_STAFF_BS.Value.AsIntIsnull();

            gLAccountPosting.GL_SUBSIDY_INT_REC_BS_ID = hidGL_SUBSIDY_INT_REC_BS.Value.AsIntIsnull();
            gLAccountPosting.GL_SUBSIDY_INT_INC_PL_ID = hidGL_SUBSIDY_INT_INC_PL.Value.AsIntIsnull();
            gLAccountPosting.GL_ACC_SUBSIDY_REV_CHG_ID = hidGL_ACC_SUBSIDY_REV_CHG.Value.AsIntIsnull();
            gLAccountPosting.GL_ADJ_SUBSIDY_REV_CHG_ID = hidGL_ADJ_SUBSIDY_REV_CHG.Value.AsIntIsnull();

            gLAccountPosting.SetStandardField();


            int iID = 0;
            iID = new SPR_GLACCOUNTPOSTING().UPDATE(gLAccountPosting);
            
            if (iID > 0)
            {                
                //this.JS_Alert(Resources.ifrsResource.SaveData, ResolveUrl(string.Format("~/IFRS/WIN31_GL_TR_2E.aspx?&id={0}", hidGLAccountPostingID.Value.AsInt32())));
                this.JS_Alert(Resources.ifrsResource.SaveData);
                this.BindData(hidGLAccountPostingID.Value.AsInt32());              
            }
            else
            {
                if (iID == -1)
                {
                    Utility.AlertMessage(Page, Resources.ifrsResource.Duplicate);
                }
                else
                {
                    Utility.AlertMessage(Page, Resources.ifrsResource.CanNotSaveData);
                }
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    private void ViewMenu()
    {
        MenuTitleBar = Resources.ifrsMenu.WIN31_GL_TR_2E;
    }
    #endregion
}